package com.sp2.dev.apachecommons;

import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.junit.Test;

/**
 * Created by IntelliJ IDEA.
 * User: zhimingli
 * Date: 14-2-25
 * Time: 下午3:38
 * 取得字符串的缩写
 */
public class StringUtilTest {
    public static void main(String[] args) {

    }

    @Test
    public void abbreviate() {
        //我们hello...
        System.out.println(StringUtils.abbreviate("我们hello hello hello hello hello hello hello", 10));

        //test
        System.out.println(StringUtils.abbreviate("test", 10));

        //...is a test...
        String test = "This is a test of the abbreviation.";
        System.out.println(StringUtils.abbreviate(test, 5, 15));
    }

    //劈分字符串
    @Test
    public void split() {
        String input = "A b,c.d|e";
        String[] array1 = StringUtils.split(input, " ,.|");
        System.out.println(ArrayUtils.toString(array1));
    }
}
